package Application.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import Application.dao.TeacherDao;
import Application.entity.Result;
import Application.entity.Student;
import Application.entity.Teacher;
import Application.service.TeacherService;
@Service("TeacherService")
public class TeacherServiceImpl implements TeacherService {

	@Resource
	private TeacherDao dao;

	@Override
	public Result insertTeacher(Teacher teacher) {
		Result r =new Result();
		try {
			dao.insertTeacher(teacher);
			r.setContent(1);
		} catch (Exception e) {
			r.setContent(0);
		}
		return r;
	}

	@Override
	public Result checklog(Teacher teacher) {
		Result r =new Result();
		try {
			List<Teacher> list=dao.findTeacherList();
			for(Teacher t :list){
				if(t.getId()==teacher.getId()&&t.getPassword()==teacher.getPassword()) {
					r.setContent(1);
					break;
				}
				r.setContent(0);
			}
		} catch (Exception e) {
			r.setContent(0);
		}
		return r;
	}

	@Override
	public Teacher findTeacherById(int id) {
		return dao.findTeacherById(id);
	}
	

}
